namespace BadHabit.Factory.Reports
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Xml.XPath;
    using System.Xml.Xsl;

    public class ResourceReport : Report
    {
        private static Data.ResourceReportDataSetTableAdapters.AssigneeEffortByMonthTableAdapter effortTA = new BadHabit.Factory.Data.ResourceReportDataSetTableAdapters.AssigneeEffortByMonthTableAdapter();

        private int month;
        private int year;

        /// <summary>
        /// Implements a Report class to generate a backlog report.
        /// </summary>
        /// <param name="factory"></param>
        public ResourceReport(FactoryLogic factory, int month, int year)
            : base(factory)
        {
            this.month = month;
            this.year = year;
        }

        /// <summary>
        /// The template type name.
        /// </summary>
        public override string TemplateTypeName
        {
            get
            {
                return "ResourceReport";
            }
        }

        /// <summary>
        /// Adjusts the dataset for XPS render.
        /// </summary>
        /// <param name="projectUId">The projectUId</param>
        /// <returns>The adjusted dataset</returns>
        public override System.Data.DataSet CreateDataSet()
        {
            Data.ResourceReportDataSet report = report = new Data.ResourceReportDataSet();
            report.EnforceConstraints = false;
            effortTA.FillByMonth(report.AssigneeEffortByMonth, this.month, this.year);
            return report;
        }

        public override System.Data.DataSet AdjustDataSet(System.Data.DataSet report)
        {
            report = base.AdjustDataSet(report);

            report.Tables.Add("GeneralRes");

            report.Tables["GeneralRes"].Columns.Add("monthName");
            report.Tables["GeneralRes"].Columns.Add("actualMonth");
            report.Tables["GeneralRes"].Columns.Add("actualYear");
            DateTime newDate = new DateTime(this.year, this.month, 1);
            report.Tables["GeneralRes"].Rows.Add(new object[] { newDate.ToString("MMMM"), DateTime.Now.Month, DateTime.Now.Year });

            return report;
        }
    }
}
